/**
 * 
 */
package cn.tonyqiu.wonuly.client.gui;

import cn.tonyqiu.wonuly.client.i18n.WonulyConstants;
import cn.tonyqiu.wonuly.client.images.WonulyImageBundle;

import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DecoratedStackPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * A composite that contain shortcuts on the left of Wonuly
 * 
 * @author <a href="mailto:tony.qiu.smart@gmail.com">Tony Qiu</a>
 * 
 */
public class Shortcuts extends Composite {

	private static final WonulyConstants constants = Wonuly.constants;
	private static final WonulyImageBundle images = Wonuly.images;
	
	private DecoratedStackPanel stackPanel = new DecoratedStackPanel();

	public Shortcuts() {
		add(new BillOperations(), images.shortcutsAccount(), constants
				.shortcutsAccount());
		add(new Label("label2"), images.shortcutsBill(), constants
				.shortcutsBill());
		add(new Label("label3"), images.shortcutsCategory(), constants
				.shortcutsCategory());
		add(new Label("label4"), images.shortcutsSchedule(), constants
				.shortcutsSchedule());
		initWidget(stackPanel);
	}

	public void onLoad() {
		stackPanel.showStack(0);
	}

	private void add(Widget widget, AbstractImagePrototype image, String caption) {
		String captionHTML = "<table class='caption' cellpadding='0' cellspacing='0'>"
				+ "<tr><td class='lcaption'>"
				+ image.getHTML()
				+ "</td><td class='rcaption'><b style='white-space:nowrap'>"
				+ caption + "</b></td></tr></table>";
		widget.addStyleName("mail-StackContent");
		stackPanel.add(widget, captionHTML, true);
	}

}
